package com.threadpool;

import java.util.concurrent.CountDownLatch;

/**
 * Created by houjinxin on 16/9/3.
 */
public class QueryDBTask implements Runnable {

    private int taskId;
    private CountDownLatch count;

    public QueryDBTask(int taskId, CountDownLatch count) {
        this.taskId = taskId;
        this.count = count;
    }

    @Override
    public void run() {
        try {
            System.out.println(Thread.currentThread().getName() + "开始执行任务" + taskId + "！");
            Thread.sleep(2000);
            System.out.println(Thread.currentThread().getName() + "执行完成！");
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            count.countDown();
        }
    }
}
